<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Submits a command and separate parameters to the server without waiting for the result(s).</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.pg-send-prepare.html">pg_send_prepare</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-send-query.html">pg_send_query</a></div>
 <div class="up"><a href="ref.pgsql.html">PostgreSQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.pg-send-query-params" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_send_query_params</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0)</p><p class="refpurpose"><span class="refname">pg_send_query_params</span> &mdash; <span class="dc-title">Submits a command and separate parameters to the server without waiting for the result(s).</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-send-query-params-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>pg_send_query_params</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$connection</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$query</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$params</code></span>
   )</div>

  <p class="para rdfs-comment">
    Submits a command and separate parameters to the server without 
    waiting for the result(s).
  </p>
  <p class="para">
    This is equivalent to <span class="function"><a href="function.pg-send-query.html" class="function">pg_send_query()</a></span> except that query 
    parameters can be specified separately from the 
    <em><code class="parameter">query</code></em> string. The function&#039;s parameters are 
    handled identically to <span class="function"><a href="function.pg-query-params.html" class="function">pg_query_params()</a></span>. Like 
    <span class="function"><a href="function.pg-query-params.html" class="function">pg_query_params()</a></span>, it will not work on pre-7.4 PostgreSQL 
    connections, and it allows only one command in the query string. 
  </p>  
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.pg-send-query-params-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">connection</code></em></dt>

     <dd>

      <p class="para">
       PostgreSQL database connection resource.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">query</code></em></dt>

     <dd>

      <p class="para">
       The parameterized SQL statement.  Must contain only a single statement.
       (multiple statements separated by semi-colons are not allowed.)  If any parameters 
       are used, they are referred to as $1, $2, etc.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">params</code></em></dt>

     <dd>

      <p class="para">
        An array of parameter values to substitute for the $1, $2, etc. placeholders
        in the original prepared query string.  The number of elements in the array
        must match the number of placeholders.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-send-query-params-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。</p>
  <p class="para">
   Use <span class="function"><a href="function.pg-get-result.html" class="function">pg_get_result()</a></span> to determine the query result.
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.pg-send-query-params-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2058">
    <p><strong>Example #1 Using <span class="function"><strong>pg_send_query_params()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;$dbconn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">)&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Using&nbsp;parameters.&nbsp;&nbsp;Note&nbsp;that&nbsp;it&nbsp;is&nbsp;not&nbsp;necessary&nbsp;to&nbsp;quote&nbsp;or&nbsp;escape<br />&nbsp;&nbsp;//&nbsp;the&nbsp;parameter.<br />&nbsp;&nbsp;</span><span style="color: #0000BB">pg_send_query_params</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'select&nbsp;count(*)&nbsp;from&nbsp;authors&nbsp;where&nbsp;city&nbsp;=&nbsp;$1'</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'Perth'</span><span style="color: #007700">));<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Compare&nbsp;against&nbsp;basic&nbsp;pg_send_query&nbsp;usage<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_escape_string</span><span style="color: #007700">(</span><span style="color: #DD0000">'Perth'</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">pg_send_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"select&nbsp;count(*)&nbsp;from&nbsp;authors&nbsp;where&nbsp;city&nbsp;=&nbsp;'</span><span style="color: #007700">${</span><span style="color: #0000BB">str</span><span style="color: #007700">}</span><span style="color: #DD0000">'"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div> 
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pg-send-query-params-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.pg-send-query.html" class="function" rel="rdfs-seeAlso">pg_send_query()</a> - 发送异步查询</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.pg-send-prepare.html">pg_send_prepare</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-send-query.html">pg_send_query</a></div>
 <div class="up"><a href="ref.pgsql.html">PostgreSQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
